package net.uiiang.android.alkaid.helper;

import java.util.ArrayList;
import java.util.List;

import net.uiiang.android.alkaid.object.FileItem;
import net.uiiang.android.alkaid.object.FileView;
import net.uiiang.android.alkaid.utils.FavoriteUtil;
import android.content.Context;
import android.database.Cursor;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleCursorAdapter;

public class FavoriteAdapter extends SimpleCursorAdapter {

    private List<FileItem> mItems = new ArrayList<FileItem>();
    private Context mContext;

    public FavoriteAdapter(Context context, int layout, Cursor c,
            String[] from, int[] to) {
        super(context, layout, c, from, to);
        mContext = context;
        mItems = FavoriteUtil.convertCursorToFileItem(c, mContext);
    }

    public Object getItem(int position) {
        return mItems.get(position);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // return super.getView(position, convertView, parent);
        FileView fView = new FileView();
        return fView.newFileView(this.mContext, (FileItem) this
                .getItem(position), false);
    }

}
